package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsOrder;
import com.qf.service.OrderService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单数据
 * @author mkr
 * @version V1.0
 * @Project java2203-mkr
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/26 17:24
 */

@RestController
@RequestMapping("/order")
@CrossOrigin("*")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/list")
    public Object orderlist(Integer userId , String orderSn , Integer orderStatus ,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "20") Integer limit,
                       @RequestParam(defaultValue = "add_time") String sort,
                       @RequestParam(defaultValue = "desc") String order){
        //获取订单数据
        IPage<DtsOrder> orderIPage = orderService.orderList(userId, orderSn, orderStatus, page, limit, sort, order);

        //获取结果集
        List<DtsOrder> records = orderIPage.getRecords();
        //获取总条数
        long total = orderIPage.getTotal();

        //封装并返回
        Map<String , Object> data = new HashMap<>();
        data.put("total", total);
        data.put("items", records);

        return ResponseUtil.ok(data);
    }

    @GetMapping("/listShipChannel")
    public Object listShipChannel(){

        return ResponseUtil.ok();
    }

    @GetMapping("/detail")
    public Object detail(@RequestBody DtsOrder order){

    }
}
